#!/bin/bash
if [ ! -d $HOME/tmux-plugins ];then
   mkdir -p $HOME/tmux-plugins;
fi

if [ -d $HOME/tmux-plugins/todo-plugin ];then
  rm -rf $HOME/tmux-plugins/todo-plugin;
fi
git clone https://gitee.com/dark.H/tmux-todo-plugin $HOME/tmux-plugins/todo-plugin;

if [ -e $HOME/.tmux.conf ];then
if grep --quiet "todo_plugin.tmux" $HOME/.tmux.conf ;then
    echo "you installed already!"
    echo "reinstall "
else
    cat << EOF >> $HOME/.tmux.conf 
run-shell $HOME/tmux-plugins/todo-plugin/todo_plugin.tmux
EOF
fi
else
    cat << EOF >> $HOME/.tmux.conf 
run-shell $HOME/tmux-plugins/todo-plugin/todo_plugin.tmux
EOF

fi

cp $HOME/tmux-plugins/todo-plugin/scripts/todo_plugin.sh $HOME/;

tmux source-file $HOME/.tmux.conf
